
/*
 ***************************************************************************
 * MediaTeK Inc.
 * 4F, No. 2 Technology	5th	Rd.
 * Science-based Industrial	Park
 * Hsin-chu, Taiwan, R.O.C.
 *
 * (c) Copyright 2002-2012, MTK.
 *
 * All rights reserved.	MediaTeK's source	code is	an unpublished work	and	the
 * use of a	copyright notice does not imply	otherwise. This	source code
 * contains	confidential trade secret material of MediaTeK Tech. Any attemp
 * or participation	in deciphering,	decoding, reverse engineering or in	any
 * way altering	the	source code	is stricitly prohibited, unless	the	prior
 * written consent of MediaTeK, Inc. is obtained.
 ***************************************************************************

	Module Name:
	omci_me_ani_management.h
	
	Abstract:

	Revision History:
	Who			When			What
	--------	----------		----------------------------------------------
	Name		Date			Modification logs
	kenny.weng		2012/8/07	Create
	Andy.Yi		        2012/8/07	add 9.2.1,9.2.2
*/


#ifndef _OMCI_ME_ANI_MANAGEMENT_H_
#define _OMCI_ME_ANI_MANAGEMENT_H_

#include "omci_me_alcatel.h"

#define TXDIRECTION 0
#define RXDIRECTION 1
#define LAN_INTERFACE 0
#define WAN_INTERFADE 1

#define MAX_GEMPORT_ID_NUM_1G 4095
#define MAX_GEMPORT_ID_NUM_10G 65534


#define DIRECTION_UNI_TO_ANI		1
#define DIRECTION_ANI_TO_UNI		2
#define DIRECTION_BIDIRECTIONAL	3


#if/*TCSUPPORT_COMPILE*/ defined(TCSUPPORT_ALPHION_PON)
	#define UP_GEMPORT_TO_METER_START	    0	
#else/*TCSUPPORT_COMPILE*/
    #define UP_GEMPORT_TO_METER_START	    10
#endif/*TCSUPPORT_COMPILE*/
#define UP_GEMPORT_TO_METER_NUM		    32
#define DOWN_GEMPORT_TO_METER_NUM		32

#define DOWN_GEMPORT_TO_METER_START	    (UP_GEMPORT_TO_METER_START+UP_GEMPORT_TO_METER_NUM)
#if defined (TCSUPPORT_OMCI_ALCATEL) && defined (TCSUPPORT_UPSTREAM_VLAN_POLICER)        
    #define TRTCM_CHAN_NUM_FOR_GEMPORT UP_GEMPORT_TO_METER_NUM
    #define CONST_SHAPING_NUM (UP_GEMPORT_TO_METER_NUM + TRTCM_CHAN_NUM_FOR_UP_STRM_POLICER) 
#else
    #define TRTCM_CHAN_NUM_FOR_GEMPORT UP_GEMPORT_TO_METER_NUM
    #define CONST_SHAPING_NUM TRTCM_CHAN_NUM_FOR_GEMPORT
#endif

#ifdef TCSUPPORT_GPON_MAPPING
#define RECONFIG_GPONMAP_RULE		(0xFFFFFFFF)
#define EMPTY_GPONMAP_RULE 		(0xFFFF)
#ifndef UP_GEMPORT_TO_METER_START
#define UP_GEMPORT_TO_METER_START	10
#endif
#ifndef UP_GEMPORT_TO_METER_NUM
#define UP_GEMPORT_TO_METER_NUM		8
#endif
#ifndef DOWN_GEMPORT_TO_METER_START
#define DOWN_GEMPORT_TO_METER_START	(UP_GEMPORT_TO_METER_START+UP_GEMPORT_TO_METER_NUM)
#endif
#endif


extern uint16_t trtcmChannel[CONST_SHAPING_NUM];

typedef struct TrtcmParam_s{
        uint32_t CIR;
        uint32_t PIR;
        uint32_t CBS;
        uint32_t PBS;
        uint8_t  chanID;
}TrtcmParam, * TrtcmParam_p;


typedef struct backPressure_s{
	uint8_t  Enable;
	uint32_t time;
	uint16_t MaxQueueThreshold;
	uint16_t MinQueueThreshold;
}backPressure_t, *backPressure_ptr;

typedef struct dropPolicy_s{
uint16_t greenPacketDropQueueMaxThr;
uint16_t greenPacketDropQueueMinThr;
uint16_t yellowPacketDropQueueMaxThr;
uint16_t yellowPacketDropQueueMinThr;
uint8_t   greenPacketDropMax_p;
uint8_t   yellowPacketDropMax_p;
uint8_t   QueueDropW_q;
uint8_t   DropPrecdenceColourMarking;
}dropPolicy_t, *dropPolicy_ptr;

typedef struct trafficDescriptor_s{
uint32_t CIR;
uint32_t PIR;
uint32_t CBS;
uint32_t PBS;
uint8_t   colourMode;
uint8_t   ingressColourMarking;
uint8_t   engressColourMarking;
uint8_t   meterType;
uint8_t 	direction;
}trafficDescriptor_t, *trafficDescriptor_ptr;



int setBoundTD(IN uint8_t portId, IN uint8_t ifcType, IN uint16_t tdInstId, IN uint8_t dir);
int cleanBoundTD(IN uint8_t portId, IN uint8_t ifcType, IN uint8_t tdInstId, IN uint8_t dir);
int omciEmptyQueueMappingRule(void);
int omciAddQueueMappingRule(omci_gem_port_ctp_ptr gem_ctp_ptr);
int omciDelQueueMappingRule(omci_gem_port_ctp_ptr gem_ctp_ptr);


int setGEMBlockLengthValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setSFThresholdValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setSDThresholdValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setANIGARCValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getOpticalSignalLevelValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setLowerOpticalThresholdValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setUpperOpticalThresholdValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getTransmitOpticalLevelValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setLowerTransmitOpticalThresholdValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setUpperTransmitOpticalThresholdValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int omci_me_ani_g_test_op(management_entry_ptr me_entry, omci_me_info_ptr me_info);

int setTCONTAllocIdValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setTCONTPolicyValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);

int omci_me_gem_ctp_create_op(management_entry_ptr me_entry, omci_me_info_ptr me_info);
int omci_me_gem_ctp_delete_op(management_entry_ptr me_entry, omci_me_info_ptr me_info);
int omci_me_gem_ctp_set_op(management_entry_ptr me_entry, omci_me_info_ptr me_info);
int getEncryptionStateValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setEncryptionKeyRingValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);

int getGemPortPmLostPacketsValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);

int getMaxQueueSizeValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getAllocQueueSizeValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setAllocQueueSizeValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setRelatePortValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setTrafficSchedPointValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getWeightValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setWeightValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getBackPressureOperatetValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setBackPressureOperatetValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getBackPressureTimeValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setBackPressureTimeValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getBackPressureOccurThredValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setBackPressureOccurThredValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getBackPressureClearThredValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setBackPressureClearThredValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getPacketDropThredValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setPacketDropThredValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getPacketDropMaxpValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setPacketDropMaxpValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getQueueDropWqValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setQueueDropWqValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int getDropPrecedenceColorMarkValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setDropPrecedenceColorMarkValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);

int setTcontPointValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int setTcontPolicyValue(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);

int omci_me_traffic_desc_create_op(management_entry_ptr me_entry, omci_me_info_ptr me_info);
int omci_me_traffic_desc_set_op(management_entry_ptr me_entry, omci_me_info_ptr me_info);

int omciReconfigQueueMappingRule(void);
float logFunction(float x, int base, int decimalplaces);


int get_gemport_pm_history_data(pm_history_data_list_ptr pm_list, uint8_t syncFlag);
int get_gemport_net_ctp_pm_history_data(pm_history_data_list_ptr pm_list, uint8_t syncFlag);
int get_energy_consumed_pm_history_data(pm_history_data_list_ptr pm_list, uint8_t syncFlag);


int omci_me_gem_port_pm_history_notify(pm_history_data_list_ptr pm_list, omci_me_info_t threshold_info);
int omci_me_gemport_net_ctp_pm_history_notify(pm_history_data_list_ptr pm_list, omci_me_info_t threshold_info);

uint64_t get64FromHL32(uint32_t high32, uint32_t low32);
int getPortIdByInstIdFromGemPortCtp(uint16_t instanceId, uint16_t *portId);

int omci_set_drop_preceduce_dei(int enable,int direction);
int omci_set_gdm_pcp_mode(int PcpMode,int direction);
void omci_clear_drop_preceduce_color_mark(void);

/*extern */
extern omci_attr_dscp_t omci_attr_ani_g_op[];
extern omci_me_func_t omci_me_ani_g_op;
extern omci_attr_t omci_ani_g_attr;

extern omci_attr_dscp_t omci_attr_t_cont_op[];
extern omci_me_func_t omci_me_t_cont_op;
extern omci_attr_t omci_t_cont_attr;

extern omci_attr_dscp_t omci_attr_gem_port_ctp_op[];
extern omci_me_func_t omci_me_gem_port_ctp_op;
extern omci_attr_t omci_gem_port_ctp_attr;

extern omci_attr_dscp_t omci_attr_gem_port_pm_op[];
extern omci_me_func_t omci_me_gem_port_pm_op;
extern omci_attr_t omci_gem_port_pm_attr;


extern omci_attr_dscp_t omci_attr_priority_queue_op[];
extern omci_me_func_t omci_me_priority_queue_op;
extern omci_attr_t omci_priority_queue_attr;

extern omci_attr_dscp_t omci_attr_traffic_scheduler_op[];
extern omci_me_func_t omci_me_traffic_scheduler_op;
extern omci_attr_t omci_traffic_scheduler_attr;

extern omci_attr_dscp_t omci_attr_traffic_descriptor_op[];
extern omci_me_func_t omci_me_traffic_descriptor_op;
extern omci_attr_t omci_traffic_descriptor_attr;

extern omci_attr_dscp_t omci_attr_gemport_net_ctp_pm_his_op[];
extern omci_me_func_t omci_me_gemport_net_ctp_pm_his_op;
extern omci_attr_t omci_gemport_net_ctp_pm_his_attr;

extern omci_attr_dscp_t omci_attr_energy_pm_his_op[];
extern omci_me_func_t omci_me_energy_pm_his_op;
extern omci_attr_t omci_energy_pm_his_attr;

#endif
